package com.kaifamiao.set;

import java.time.LocalDate;
import java.util.Objects;

public class Panda {

    private String name;
    private LocalDate birthdate;

    public Panda(String name, LocalDate birthdate) {
        this.name = name;
        this.birthdate = birthdate;
    }

    @Override
    public boolean equals(Object another) {
        System.out.println( "equals" );
        if (this == another) {
            return true;
        }
        if (another == null || getClass() != another.getClass()) {
            return false;
        }
        Panda panda = (Panda) another;
        return Objects.equals(name, panda.name) &&
               Objects.equals(birthdate, panda.birthdate);
    }

    @Override
    public int hashCode() {
        int hash = Objects.hash(name, birthdate);
        System.out.println( this + ":" + hash );
        return hash;
    }

    @Override
    public String toString() {
        return String.format("(%s,%s)", name, birthdate );
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public LocalDate getBirthdate() {
        return birthdate;
    }

    public void setBirthdate(LocalDate birthdate) {
        this.birthdate = birthdate;
    }
}
